@thallylabs/migrate 0.2.35 → 0.2.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -9095,7 +9095,14 @@ ${normalized.slice(1).map((row) => `| ${row.join(" | ")} |`).join("\n")}
9095
9095
  const fragment = load2(element.outerHTML);
9096
9096
  const tokenLines = fragment(".token-line").toArray();
9097
9097
  const code = (tokenLines.length > 0 ? tokenLines.map((line) => fragment(line).text()).join("\n") : fragment("pre").text()).replace(/\n$/, "");
9098
- const language = fragment("code").attr("class")?.match(/(?:language-|lang-)([A-Za-z0-9_+-]+)/)?.[1] ?? "";
9098
+ const language = ["code", "pre"].flatMap((selector) => {
9099
+ const block = fragment(selector).first();
9100
+ return [
9101
+ block.attr("language"),
9102
+ block.attr("data-language"),
9103
+ block.attr("class")?.match(/(?:^|\s)(?:language-|lang-)([A-Za-z0-9_+-]+)(?=\s|$)/)?.[1]
9104
+ ];
9105
+ }).find((value) => value !== void 0 && /^[A-Za-z0-9_+-]{1,64}$/.test(value)) ?? "";
9099
9106
  const longestFence = Math.max(0, ...[...code.matchAll(/`+/g)].map((match) => match[0].length));
9100
9107
  const fence = "`".repeat(Math.max(3, longestFence + 1));
9101
9108
  return `
@@ -15412,7 +15419,7 @@ function validateUrlMigration(checkpoint, cancelled = false) {
15412
15419
  } catch {
15413
15420
  }
15414
15421
  if (!destination.evidence?.anchors.includes(anchor)) {
15415
- warnings.push({ code: "source-link-warning", source: record.url, message: `The original source link refers to an absent source anchor: ${link}` });
15422
+ warnings.push({ code: "source-link-warning", source: record.url, message: `The original source link refers to an absent source anchor; the imported link opens the page instead: ${link}` });
15416
15423
  } else if (destination.page) {
15417
15424
  const nodes = markdownNodes(destination.page.body);
15418
15425
  const explicit = nodes.flatMap((node) => node.name === "a" ? (node.attributes ?? []).flatMap((attribute) => attribute.name === "id" && typeof attribute.value === "string" ? [attribute.value] : []) : []);
@@ -15861,8 +15868,17 @@ ${difference}`;
15861
15868
  } catch {
15862
15869
  return value;
15863
15870
  }
15864
- const route = routeMap.get(canonical(url.toString(), sourceUrl));
15865
- return route ? `${route}${url.hash}` : value;
15871
+ const identity = canonical(url.toString(), sourceUrl);
15872
+ const route = routeMap.get(identity);
15873
+ if (!route) return value;
15874
+ const destination = resolveMigrationRecord(records, records.get(identity));
15875
+ let anchor = url.hash.slice(1);
15876
+ try {
15877
+ anchor = decodeURIComponent(anchor);
15878
+ } catch {
15879
+ }
15880
+ const hasBrokenSourceAnchor = Boolean(url.hash && destination?.outcome === "imported" && destination.evidence && !destination.evidence.anchors.includes(anchor));
15881
+ return `${route}${hasBrokenSourceAnchor ? "" : url.hash}`;
15866
15882
  }) }] : []);
15867
15883
  const validation = validateUrlMigration(checkpoint, Boolean(options.signal?.aborted));
15868
15884
  validation.issues.push(...navigationIssues);